package com.hlhj.funlike_business.moudle;

import android.content.Context;

import com.example.mymvp.mvp.BaseModule;
import com.hlhj.funlike_business.api.Apis;
import com.hlhj.funlike_business.api.BaseObser;
import com.hlhj.funlike_business.bean.MsgBean;
import com.hlhj.funlike_business.bean.OrderListBean;
import com.lzy.okgo.model.Response;

import java.util.List;

public class WaitTakeFragmentMoulde implements BaseModule{
    public interface getOrderLsit{
        void loadOrderList(OrderListBean.DataBeanX dataBeans);

        void loadResult(String msg);
    }

    public getOrderLsit listener;

    public void setListener(getOrderLsit listener) {
        this.listener = listener;
    }

    public void LoadOrderList(Context context, int status, int p, int num){
        Apis.INSTANCE.OrderList(status,p,num)
                .subscribe(new BaseObser<Response<OrderListBean>>(context) {
                    @Override
                    public void httpSuccess(Response<OrderListBean> orderListBeanResponse) {
                        if (listener!=null){
                            listener.loadOrderList(orderListBeanResponse.body().getData());
                        }
                    }
                });
    }

    public void LoadResult(Context context,int order_id,int status){
        Apis.INSTANCE.EditOrderStatus(order_id,status)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.loadResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }

    public void LoadChargeBack(Context context,int order_id){
        Apis.INSTANCE.OrderChargeBack(order_id)
                .subscribe(new BaseObser<Response<MsgBean>>(context) {
                    @Override
                    public void httpSuccess(Response<MsgBean> msgBeanResponse) {
                        if (listener!=null){
                            listener.loadResult(msgBeanResponse.body().getMsg());
                        }
                    }
                });
    }
}
